const { Article} = require('../../model/article')
module.exports = async (req,res) => {
    req.app.locals.currentLink = 'article'
    let id = req.query.id

    if(id) {

        let result = await Article.findOne({_id:id}).populate('author')
        // console.log(result);
        
        res.render('../views/admin/article-edit',{
            article:result,
            url:'/admin/article-edit?id='+id
        })
    }
    else {
        res.render('../views/admin/article-edit',{
            url:'/admin/article-add'
        })
    }

    

}